package com.ruoyi.edit.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.edit.domain.DevelopReview;
import com.ruoyi.edit.service.IDevelopReviewService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 核检月Controller
 * 
 * @author qiufeng
 * @date 2022-05-10
 */
@Controller
@RequestMapping("/system/developReview")
public class DevelopReviewController extends BaseController
{
    private String prefix = "system/developReview";

    @Autowired
    private IDevelopReviewService developReviewService;

    @GetMapping()
    public String developReview()
    {
        return prefix + "/developReview";
    }

    /**
     * 查询核检月列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DevelopReview developReview)
    {
        startPage();
        List<DevelopReview> list = developReviewService.selectDevelopReviewList(developReview);
        return getDataTable(list);
    }

    /**
     * 导出核检月列表
     */
    @Log(title = "核检月", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DevelopReview developReview)
    {
        List<DevelopReview> list = developReviewService.selectDevelopReviewList(developReview);
        ExcelUtil<DevelopReview> util = new ExcelUtil<DevelopReview>(DevelopReview.class);
        return util.exportExcel(list, "核检月数据");
    }

    /**
     * 新增核检月
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存核检月
     */
    @Log(title = "核检月", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DevelopReview developReview)
    {
        return toAjax(developReviewService.insertDevelopReview(developReview));
    }

    /**
     * 修改核检月
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        DevelopReview developReview = developReviewService.selectDevelopReviewById(id);
        mmap.put("developReview", developReview);
        return prefix + "/edit";
    }

    /**
     * 修改保存核检月
     */
    @Log(title = "核检月", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DevelopReview developReview)
    {
        return toAjax(developReviewService.updateDevelopReview(developReview));
    }

    /**
     * 删除核检月
     */
    @Log(title = "核检月", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(developReviewService.deleteDevelopReviewByIds(ids));
    }
}
